/********************************************************************
FileName    :   Dal_yw_pdbH.cs
CreateTime  :   2015-09-18 12:09
BaseClass   :   Dal_yw_pdbH
FileType    :   .cs
Author      :  minjie
Description :   Dal_yw_pdbHDAL层（简单三层）
*********************************************************************/

using System;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;

using System.Data;
namespace OS.DAL
{
    /// <summary>
    /// Dal_yw_pdbH的摘要说明。
    /// </summary>
    public partial class Dal_yw_pdbH
    {

        public bool Exists(int DjLsh)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from yw_pdbH");
            strSql.Append(" where DjLsh=@DjLsh");
            SqlParameter[] parameters = { new SqlParameter("@DjLsh", SqlDbType.Int, 4) };
            parameters[0].Value = DjLsh;
            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }
        public bool Exists(string pddh,ref int djlsh)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Djlsh from yw_pdbH");
            strSql.Append(" where  pddh='"+ pddh + "' ");

            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj != null && obj.ToString() != "")
            {
                djlsh = int.Parse(obj.ToString());
                return true;
            }
            else
                return false;
        }



        /// <summary> 
        /// 增加一条数据 
        /// </summary> 
        public bool Add(yw_pdbH_Entity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into yw_pdbH(");
            strSql.Append("DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,pdrq,pdsj,djzt,pddh,bmmc,bmh,ckbh,ckmc,pdlb,gysmc,pdfs,pdslhj,pdjehj,pdjjjehe,zmslhj,zmjehj,zmjjjehe,ykslhj,ykjehj,ykjjjehe,bz,zdr,zdsj,shr,shsj,sjfs) values (");
            strSql.Append("	@DjLsh,@DjBtZdh,@DjFtZdh,@DjStZdh,@DjState,@DjCount,@pdrq,@pdsj,@djzt,@pddh,@bmmc,@bmh,@ckbh,@ckmc,@pdlb,@gysmc,@pdfs,@pdslhj,@pdjehj,@pdjjjehe,@zmslhj,@zmjehj,@zmjjjehe,@ykslhj,@ykjehj,@ykjjjehe,@bz,@zdr,@zdsj,@shr,@shsj,@sjfs	 ) ");
            SqlParameter[] parameters = {
              new SqlParameter("@DjLsh", SqlDbType.Int,4) ,
              new SqlParameter("@DjBtZdh", SqlDbType.Int,4) ,
              new SqlParameter("@DjFtZdh", SqlDbType.Int,4) ,
              new SqlParameter("@DjStZdh", SqlDbType.Int,4) ,
              new SqlParameter("@DjState", SqlDbType.Char,10) ,
              new SqlParameter("@DjCount", SqlDbType.Int,4) ,
              new SqlParameter("@pdrq", SqlDbType.DateTime) ,
              new SqlParameter("@pdsj", SqlDbType.DateTime) ,
              new SqlParameter("@djzt", SqlDbType.VarChar,50) ,
              new SqlParameter("@pddh", SqlDbType.VarChar,50) ,
              new SqlParameter("@bmmc", SqlDbType.VarChar,50) ,
              new SqlParameter("@bmh", SqlDbType.VarChar,50) ,
              new SqlParameter("@ckbh", SqlDbType.VarChar,50) ,
              new SqlParameter("@ckmc", SqlDbType.VarChar,50) ,
              new SqlParameter("@pdlb", SqlDbType.VarChar,50) ,
              new SqlParameter("@gysmc", SqlDbType.VarChar,50) ,
              new SqlParameter("@pdfs", SqlDbType.VarChar,50) ,
              new SqlParameter("@pdslhj", SqlDbType.Decimal,9) ,
              new SqlParameter("@pdjehj", SqlDbType.Decimal,9) ,
              new SqlParameter("@pdjjjehe", SqlDbType.Decimal,9) ,
              new SqlParameter("@zmslhj", SqlDbType.Decimal,9) ,
              new SqlParameter("@zmjehj", SqlDbType.Decimal,9) ,
              new SqlParameter("@zmjjjehe", SqlDbType.Decimal,9) ,
              new SqlParameter("@ykslhj", SqlDbType.Decimal,9) ,
              new SqlParameter("@ykjehj", SqlDbType.Decimal,9) ,
              new SqlParameter("@ykjjjehe", SqlDbType.Decimal,9) ,
              new SqlParameter("@bz", SqlDbType.VarChar,50) ,
              new SqlParameter("@zdr", SqlDbType.VarChar,50) ,
              new SqlParameter("@zdsj", SqlDbType.DateTime) ,
              new SqlParameter("@shr", SqlDbType.VarChar,50) ,
              new SqlParameter("@shsj", SqlDbType.DateTime) ,
              new SqlParameter("@sjfs", SqlDbType.VarChar,50)};
            parameters[0].Value = model.DjLsh;

            parameters[1].Value = model.DjBtZdh;

            parameters[2].Value = model.DjFtZdh;

            parameters[3].Value = model.DjStZdh;

            if (model.DjState != null)
                parameters[4].Value = model.DjState;
            else
                parameters[4].Value = DBNull.Value;

            parameters[5].Value = model.DjCount;

            if (model.pdrq != null)
                parameters[6].Value = model.pdrq;
            else
                parameters[6].Value = DBNull.Value;

            if (model.pdsj != null)
                parameters[7].Value = model.pdsj;
            else
                parameters[7].Value = DBNull.Value;

            if (model.djzt != null)
                parameters[8].Value = model.djzt;
            else
                parameters[8].Value = DBNull.Value;

            if (model.pddh != null)
                parameters[9].Value = model.pddh;
            else
                parameters[9].Value = DBNull.Value;

            if (model.bmmc != null)
                parameters[10].Value = model.bmmc;
            else
                parameters[10].Value = DBNull.Value;

            if (model.bmh != null)
                parameters[11].Value = model.bmh;
            else
                parameters[11].Value = DBNull.Value;

            if (model.ckbh != null)
                parameters[12].Value = model.ckbh;
            else
                parameters[12].Value = DBNull.Value;

            if (model.ckmc != null)
                parameters[13].Value = model.ckmc;
            else
                parameters[13].Value = DBNull.Value;

            if (model.pdlb != null)
                parameters[14].Value = model.pdlb;
            else
                parameters[14].Value = DBNull.Value;

            if (model.gysmc != null)
                parameters[15].Value = model.gysmc;
            else
                parameters[15].Value = DBNull.Value;

            if (model.pdfs != null)
                parameters[16].Value = model.pdfs;
            else
                parameters[16].Value = DBNull.Value;

            if (model.pdslhj != null)
                parameters[17].Value = model.pdslhj;
            else
                parameters[17].Value = DBNull.Value;

            if (model.pdjehj != null)
                parameters[18].Value = model.pdjehj;
            else
                parameters[18].Value = DBNull.Value;

            if (model.pdjjjehe != null)
                parameters[19].Value = model.pdjjjehe;
            else
                parameters[19].Value = DBNull.Value;

            if (model.zmslhj != null)
                parameters[20].Value = model.zmslhj;
            else
                parameters[20].Value = DBNull.Value;

            if (model.zmjehj != null)
                parameters[21].Value = model.zmjehj;
            else
                parameters[21].Value = DBNull.Value;

            if (model.zmjjjehe != null)
                parameters[22].Value = model.zmjjjehe;
            else
                parameters[22].Value = DBNull.Value;

            if (model.ykslhj != null)
                parameters[23].Value = model.ykslhj;
            else
                parameters[23].Value = DBNull.Value;

            if (model.ykjehj != null)
                parameters[24].Value = model.ykjehj;
            else
                parameters[24].Value = DBNull.Value;

            if (model.ykjjjehe != null)
                parameters[25].Value = model.ykjjjehe;
            else
                parameters[25].Value = DBNull.Value;

            if (model.bz != null)
                parameters[26].Value = model.bz;
            else
                parameters[26].Value = DBNull.Value;

            if (model.zdr != null)
                parameters[27].Value = model.zdr;
            else
                parameters[27].Value = DBNull.Value;

            if (model.zdsj != null)
                parameters[28].Value = model.zdsj;
            else
                parameters[28].Value = DBNull.Value;

            if (model.shr != null)
                parameters[29].Value = model.shr;
            else
                parameters[29].Value = DBNull.Value;

            if (model.shsj != null)
                parameters[30].Value = model.shsj;
            else
                parameters[30].Value = DBNull.Value;

            if (model.sjfs != null)
                parameters[31].Value = model.sjfs;
            else
                parameters[31].Value = DBNull.Value;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false; ;
            }
        }

        /// <summary> 
        /// 增加一条数据(字符串) 
        /// </summary> 
        public string AddStr(yw_pdbH_Entity model)
        {
            if (model.DjLsh == null)
            {
                model.DjLsh = 0;
            }
            if (model.DjBtZdh == null)
            {
                model.DjBtZdh = 0;
            }
            if (model.DjFtZdh == null)
            {
                model.DjFtZdh = 0;
            }
            if (model.DjStZdh == null)
            {
                model.DjStZdh = 0;
            }
            if (model.DjState == null)
            {
                model.DjState = "";
            }
            if (model.DjCount == null)
            {
                model.DjCount = 0;
            }
            if (model.djzt == null)
            {
                model.djzt = "";
            }
            if (model.pddh == null)
            {
                model.pddh = "";
            }
            if (model.bmmc == null)
            {
                model.bmmc = "";
            }
            if (model.bmh == null)
            {
                model.bmh = "";
            }
            if (model.ckbh == null)
            {
                model.ckbh = "";
            }
            if (model.ckmc == null)
            {
                model.ckmc = "";
            }
            if (model.pdlb == null)
            {
                model.pdlb = "";
            }
            if (model.gysmc == null)
            {
                model.gysmc = "";
            }
            if (model.pdfs == null)
            {
                model.pdfs = "";
            }
            if (model.pdslhj == null)
            {
                model.pdslhj = 0;
            }
            if (model.pdjehj == null)
            {
                model.pdjehj = 0;
            }
            if (model.pdjjjehe == null)
            {
                model.pdjjjehe = 0;
            }
            if (model.zmslhj == null)
            {
                model.zmslhj = 0;
            }
            if (model.zmjehj == null)
            {
                model.zmjehj = 0;
            }
            if (model.zmjjjehe == null)
            {
                model.zmjjjehe = 0;
            }
            if (model.ykslhj == null)
            {
                model.ykslhj = 0;
            }
            if (model.ykjehj == null)
            {
                model.ykjehj = 0;
            }
            if (model.ykjjjehe == null)
            {
                model.ykjjjehe = 0;
            }
            if (model.bz == null)
            {
                model.bz = "";
            }
            if (model.zdr == null)
            {
                model.zdr = "";
            }
            if (model.shr == null)
            {
                model.shr = "";
            }
            if (model.sjfs == null)
            {
                model.sjfs = "";
            }

            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into yw_pdbH(");
            strSql.Append("DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,pdrq,pdsj,djzt,pddh,bmmc,bmh,ckbh,ckmc,pdlb,gysmc,pdfs,pdslhj,pdjehj,pdjjjehe,zmslhj,zmjehj,zmjjjehe,ykslhj,ykjehj,ykjjjehe,bz,zdr,zdsj,shr,shsj,sjfs) values (");
            strSql.Append("	" + model.DjLsh + "," + model.DjBtZdh + "," + model.DjFtZdh + "," + model.DjStZdh + ",'" + model.DjState + "'," + model.DjCount + ",'" + model.pdrq + "','" + model.pdsj + "','" + model.djzt + "','" + model.pddh + "','" + model.bmmc + "','" + model.bmh + "','" + model.ckbh + "','" + model.ckmc + "','" + model.pdlb + "','" + model.gysmc + "','" + model.pdfs + "'," + model.pdslhj + "," + model.pdjehj + "," + model.pdjjjehe + "," + model.zmslhj + "," + model.zmjehj + "," + model.zmjjjehe + "," + model.ykslhj + "," + model.ykjehj + "," + model.ykjjjehe + ",'" + model.bz + "','" + model.zdr + "','" + model.zdsj + "','" + model.shr + "','" + model.shsj + "','" + model.sjfs + "'	 ) ");
            return strSql.ToString();
        }


        /// <summary> 
        /// 更新一条数据 
        /// </summary> 
        public bool Update(yw_pdbH_Entity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update yw_pdbH set ");
            strSql.Append(" DjLsh = @DjLsh,");
            strSql.Append(" DjBtZdh = @DjBtZdh,");
            strSql.Append(" DjFtZdh = @DjFtZdh,");
            strSql.Append(" DjStZdh = @DjStZdh,");
            strSql.Append(" DjState = @DjState,");
            strSql.Append(" DjCount = @DjCount,");
            strSql.Append(" pdrq = @pdrq,");
            strSql.Append(" pdsj = @pdsj,");
            strSql.Append(" djzt = @djzt,");
            strSql.Append(" pddh = @pddh,");
            strSql.Append(" bmmc = @bmmc,");
            strSql.Append(" bmh = @bmh,");
            strSql.Append(" ckbh = @ckbh,");
            strSql.Append(" ckmc = @ckmc,");
            strSql.Append(" pdlb = @pdlb,");
            strSql.Append(" gysmc = @gysmc,");
            strSql.Append(" pdfs = @pdfs,");
            strSql.Append(" pdslhj = @pdslhj,");
            strSql.Append(" pdjehj = @pdjehj,");
            strSql.Append(" pdjjjehe = @pdjjjehe,");
            strSql.Append(" zmslhj = @zmslhj,");
            strSql.Append(" zmjehj = @zmjehj,");
            strSql.Append(" zmjjjehe = @zmjjjehe,");
            strSql.Append(" ykslhj = @ykslhj,");
            strSql.Append(" ykjehj = @ykjehj,");
            strSql.Append(" ykjjjehe = @ykjjjehe,");
            strSql.Append(" bz = @bz,");
            strSql.Append(" zdr = @zdr,");
            strSql.Append(" zdsj = @zdsj,");
            strSql.Append(" shr = @shr,");
            strSql.Append(" shsj = @shsj,");
            strSql.Append(" sjfs = @sjfs");
            strSql.Append(" where  DjLsh=@DjLsh ");

            SqlParameter[] parameters = {
              new SqlParameter("@DjLsh", SqlDbType.Int,4) ,
              new SqlParameter("@DjBtZdh", SqlDbType.Int,4) ,
              new SqlParameter("@DjFtZdh", SqlDbType.Int,4) ,
              new SqlParameter("@DjStZdh", SqlDbType.Int,4) ,
              new SqlParameter("@DjState", SqlDbType.Char,10) ,
              new SqlParameter("@DjCount", SqlDbType.Int,4) ,
              new SqlParameter("@pdrq", SqlDbType.DateTime) ,
              new SqlParameter("@pdsj", SqlDbType.DateTime) ,
              new SqlParameter("@djzt", SqlDbType.VarChar,50) ,
              new SqlParameter("@pddh", SqlDbType.VarChar,50) ,
              new SqlParameter("@bmmc", SqlDbType.VarChar,50) ,
              new SqlParameter("@bmh", SqlDbType.VarChar,50) ,
              new SqlParameter("@ckbh", SqlDbType.VarChar,50) ,
              new SqlParameter("@ckmc", SqlDbType.VarChar,50) ,
              new SqlParameter("@pdlb", SqlDbType.VarChar,50) ,
              new SqlParameter("@gysmc", SqlDbType.VarChar,50) ,
              new SqlParameter("@pdfs", SqlDbType.VarChar,50) ,
              new SqlParameter("@pdslhj", SqlDbType.Decimal,9) ,
              new SqlParameter("@pdjehj", SqlDbType.Decimal,9) ,
              new SqlParameter("@pdjjjehe", SqlDbType.Decimal,9) ,
              new SqlParameter("@zmslhj", SqlDbType.Decimal,9) ,
              new SqlParameter("@zmjehj", SqlDbType.Decimal,9) ,
              new SqlParameter("@zmjjjehe", SqlDbType.Decimal,9) ,
              new SqlParameter("@ykslhj", SqlDbType.Decimal,9) ,
              new SqlParameter("@ykjehj", SqlDbType.Decimal,9) ,
              new SqlParameter("@ykjjjehe", SqlDbType.Decimal,9) ,
              new SqlParameter("@bz", SqlDbType.VarChar,50) ,
              new SqlParameter("@zdr", SqlDbType.VarChar,50) ,
              new SqlParameter("@zdsj", SqlDbType.DateTime) ,
              new SqlParameter("@shr", SqlDbType.VarChar,50) ,
              new SqlParameter("@shsj", SqlDbType.DateTime) ,
              new SqlParameter("@sjfs", SqlDbType.VarChar,50)};
            parameters[0].Value = model.DjLsh;

            parameters[1].Value = model.DjBtZdh;

            parameters[2].Value = model.DjFtZdh;

            parameters[3].Value = model.DjStZdh;

            if (model.DjState != null)
                parameters[4].Value = model.DjState;
            else
                parameters[4].Value = DBNull.Value;

            parameters[5].Value = model.DjCount;

            if (model.pdrq != null)
                parameters[6].Value = model.pdrq;
            else
                parameters[6].Value = DBNull.Value;

            if (model.pdsj != null)
                parameters[7].Value = model.pdsj;
            else
                parameters[7].Value = DBNull.Value;

            if (model.djzt != null)
                parameters[8].Value = model.djzt;
            else
                parameters[8].Value = DBNull.Value;

            if (model.pddh != null)
                parameters[9].Value = model.pddh;
            else
                parameters[9].Value = DBNull.Value;

            if (model.bmmc != null)
                parameters[10].Value = model.bmmc;
            else
                parameters[10].Value = DBNull.Value;

            if (model.bmh != null)
                parameters[11].Value = model.bmh;
            else
                parameters[11].Value = DBNull.Value;

            if (model.ckbh != null)
                parameters[12].Value = model.ckbh;
            else
                parameters[12].Value = DBNull.Value;

            if (model.ckmc != null)
                parameters[13].Value = model.ckmc;
            else
                parameters[13].Value = DBNull.Value;

            if (model.pdlb != null)
                parameters[14].Value = model.pdlb;
            else
                parameters[14].Value = DBNull.Value;

            if (model.gysmc != null)
                parameters[15].Value = model.gysmc;
            else
                parameters[15].Value = DBNull.Value;

            if (model.pdfs != null)
                parameters[16].Value = model.pdfs;
            else
                parameters[16].Value = DBNull.Value;

            if (model.pdslhj != null)
                parameters[17].Value = model.pdslhj;
            else
                parameters[17].Value = DBNull.Value;

            if (model.pdjehj != null)
                parameters[18].Value = model.pdjehj;
            else
                parameters[18].Value = DBNull.Value;

            if (model.pdjjjehe != null)
                parameters[19].Value = model.pdjjjehe;
            else
                parameters[19].Value = DBNull.Value;

            if (model.zmslhj != null)
                parameters[20].Value = model.zmslhj;
            else
                parameters[20].Value = DBNull.Value;

            if (model.zmjehj != null)
                parameters[21].Value = model.zmjehj;
            else
                parameters[21].Value = DBNull.Value;

            if (model.zmjjjehe != null)
                parameters[22].Value = model.zmjjjehe;
            else
                parameters[22].Value = DBNull.Value;

            if (model.ykslhj != null)
                parameters[23].Value = model.ykslhj;
            else
                parameters[23].Value = DBNull.Value;

            if (model.ykjehj != null)
                parameters[24].Value = model.ykjehj;
            else
                parameters[24].Value = DBNull.Value;

            if (model.ykjjjehe != null)
                parameters[25].Value = model.ykjjjehe;
            else
                parameters[25].Value = DBNull.Value;

            if (model.bz != null)
                parameters[26].Value = model.bz;
            else
                parameters[26].Value = DBNull.Value;

            if (model.zdr != null)
                parameters[27].Value = model.zdr;
            else
                parameters[27].Value = DBNull.Value;

            if (model.zdsj != null)
                parameters[28].Value = model.zdsj;
            else
                parameters[28].Value = DBNull.Value;

            if (model.shr != null)
                parameters[29].Value = model.shr;
            else
                parameters[29].Value = DBNull.Value;

            if (model.shsj != null)
                parameters[30].Value = model.shsj;
            else
                parameters[30].Value = DBNull.Value;

            if (model.sjfs != null)
                parameters[31].Value = model.sjfs;
            else
                parameters[31].Value = DBNull.Value;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        public string UpdateStr(yw_pdbH_Entity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update yw_pdbH set ");
           // strSql.Append(" DjLsh = @DjLsh,");
            strSql.Append(" DjBtZdh = "+model.DjBtZdh+",");
            strSql.Append(" DjFtZdh = "+ model.DjFtZdh + ",");
            strSql.Append(" DjStZdh = "+ model.DjStZdh + ",");
            strSql.Append(" DjState = '"+ model.DjState + "',");
            strSql.Append(" DjCount ='" + model.DjCount + "' ,");
            strSql.Append(" pdrq = '" + model.pdrq + "',");
            strSql.Append(" pdsj ='" + model.pdsj + "' ,");
            strSql.Append(" djzt ='" + model.djzt + "' ,");
            strSql.Append(" pddh ='" + model.pddh + "' ,");
            strSql.Append(" bmmc ='" + model.bmmc + "' ,");
            strSql.Append(" bmh ='" + model.bmh + "' ,");
            strSql.Append(" ckbh ='" + model.ckbh + "' ,");
            strSql.Append(" ckmc = '" + model.ckmc + "',");
            strSql.Append(" pdlb = '" + model.pdlb + "',");
            strSql.Append(" gysmc ='" + model.gysmc + "' ,");
            strSql.Append(" pdfs = '" + model.pdfs + "',");
            strSql.Append(" pdslhj ='" + model.pdslhj + "' ,");
            strSql.Append(" pdjehj ='" + model.pdjehj + "' ,");
            strSql.Append(" pdjjjehe ='" + model.pdjjjehe + "' ,");
            strSql.Append(" zmslhj ='" + model.zmslhj + "' ,");
            strSql.Append(" zmjehj ='" + model.zmjehj + "' ,");
            strSql.Append(" zmjjjehe = '" + model.zmjjjehe + "',");
            strSql.Append(" ykslhj = '" + model.ykslhj + "',");
            strSql.Append(" ykjehj ='" + model.ykjehj + "' ,");
            strSql.Append(" ykjjjehe ='" + model.ykjjjehe + "' ,");
            strSql.Append(" bz = '" + model.bz + "',");
            strSql.Append(" zdr = '" + model.zdr + "',");
            strSql.Append(" zdsj = '" + model.zdsj + "',");
            strSql.Append(" shr = '" + model.shr + "',");
            strSql.Append(" shsj ='" + model.sjfs + "' ,");
            strSql.Append(" sjfs = '" + model.sjfs + "'");
            strSql.Append(" where  DjLsh= "+ model.DjLsh);


            return strSql.ToString();
        }

        /// <summary> 
        /// 删除一条数据 
        /// </summary> 
        public bool Delete(int DjLsh)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from yw_pdbH ");
            strSql.Append(" where  DjLsh=@DjLsh");
            SqlParameter[] parameters = { new SqlParameter("@DjLsh", SqlDbType.Int, 4) };
            parameters[0].Value = DjLsh;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary> 
        /// 批量删除一批数据 
        /// </summary> 
        public bool DeleteList(string DjLshlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from yw_pdbH ");
            strSql.Append(" where ID in (" + DjLshlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary> 
        /// 得到一个对象实体 
        /// </summary> 
        public yw_pdbH_Entity GetModel(int DjLsh)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,pdrq,pdsj,djzt,pddh,bmmc,bmh,ckbh,ckmc,pdlb,gysmc,pdfs,pdslhj,pdjehj,pdjjjehe,zmslhj,zmjehj,zmjjjehe,ykslhj,ykjehj,ykjjjehe,bz,zdr,zdsj,shr,shsj,sjfs");
            strSql.Append("  from yw_pdbH");
            strSql.Append(" where  DjLsh=@DjLsh ");
            SqlParameter[] parameters = { new SqlParameter("@DjLsh", SqlDbType.Int, 4) };
            parameters[0].Value = DjLsh;

            yw_pdbH_Entity model = new yw_pdbH_Entity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                DataTable dt = ds.Tables[0];
                if (dt.Rows[0]["DjLsh"] != null && dt.Rows[0]["DjLsh"].ToString() != "")
                {
                    model.DjLsh = int.Parse(dt.Rows[0]["DjLsh"].ToString());
                }
                if (dt.Rows[0]["DjBtZdh"] != null && dt.Rows[0]["DjBtZdh"].ToString() != "")
                {
                    model.DjBtZdh = int.Parse(dt.Rows[0]["DjBtZdh"].ToString());
                }
                if (dt.Rows[0]["DjFtZdh"] != null && dt.Rows[0]["DjFtZdh"].ToString() != "")
                {
                    model.DjFtZdh = int.Parse(dt.Rows[0]["DjFtZdh"].ToString());
                }
                if (dt.Rows[0]["DjStZdh"] != null && dt.Rows[0]["DjStZdh"].ToString() != "")
                {
                    model.DjStZdh = int.Parse(dt.Rows[0]["DjStZdh"].ToString());
                }
                model.DjState = dt.Rows[0]["DjState"].ToString();
                if (dt.Rows[0]["DjCount"] != null && dt.Rows[0]["DjCount"].ToString() != "")
                {
                    model.DjCount = int.Parse(dt.Rows[0]["DjCount"].ToString());
                }
                if (dt.Rows[0]["pdrq"] != null && dt.Rows[0]["pdrq"].ToString() != "")
                {
                    model.pdrq = DateTime.Parse(dt.Rows[0]["pdrq"].ToString());
                }
                if (dt.Rows[0]["pdsj"] != null && dt.Rows[0]["pdsj"].ToString() != "")
                {
                    model.pdsj = DateTime.Parse(dt.Rows[0]["pdsj"].ToString());
                }
                model.djzt = dt.Rows[0]["djzt"].ToString();
                model.pddh = dt.Rows[0]["pddh"].ToString();
                model.bmmc = dt.Rows[0]["bmmc"].ToString();
                model.bmh = dt.Rows[0]["bmh"].ToString();
                model.ckbh = dt.Rows[0]["ckbh"].ToString();
                model.ckmc = dt.Rows[0]["ckmc"].ToString();
                model.pdlb = dt.Rows[0]["pdlb"].ToString();
                model.gysmc = dt.Rows[0]["gysmc"].ToString();
                model.pdfs = dt.Rows[0]["pdfs"].ToString();
                if (dt.Rows[0]["pdslhj"] != null && dt.Rows[0]["pdslhj"].ToString() != "")
                {
                    model.pdslhj = decimal.Parse(dt.Rows[0]["pdslhj"].ToString());
                }
                if (dt.Rows[0]["pdjehj"] != null && dt.Rows[0]["pdjehj"].ToString() != "")
                {
                    model.pdjehj = decimal.Parse(dt.Rows[0]["pdjehj"].ToString());
                }
                if (dt.Rows[0]["pdjjjehe"] != null && dt.Rows[0]["pdjjjehe"].ToString() != "")
                {
                    model.pdjjjehe = decimal.Parse(dt.Rows[0]["pdjjjehe"].ToString());
                }
                if (dt.Rows[0]["zmslhj"] != null && dt.Rows[0]["zmslhj"].ToString() != "")
                {
                    model.zmslhj = decimal.Parse(dt.Rows[0]["zmslhj"].ToString());
                }
                if (dt.Rows[0]["zmjehj"] != null && dt.Rows[0]["zmjehj"].ToString() != "")
                {
                    model.zmjehj = decimal.Parse(dt.Rows[0]["zmjehj"].ToString());
                }
                if (dt.Rows[0]["zmjjjehe"] != null && dt.Rows[0]["zmjjjehe"].ToString() != "")
                {
                    model.zmjjjehe = decimal.Parse(dt.Rows[0]["zmjjjehe"].ToString());
                }
                if (dt.Rows[0]["ykslhj"] != null && dt.Rows[0]["ykslhj"].ToString() != "")
                {
                    model.ykslhj = decimal.Parse(dt.Rows[0]["ykslhj"].ToString());
                }
                if (dt.Rows[0]["ykjehj"] != null && dt.Rows[0]["ykjehj"].ToString() != "")
                {
                    model.ykjehj = decimal.Parse(dt.Rows[0]["ykjehj"].ToString());
                }
                if (dt.Rows[0]["ykjjjehe"] != null && dt.Rows[0]["ykjjjehe"].ToString() != "")
                {
                    model.ykjjjehe = decimal.Parse(dt.Rows[0]["ykjjjehe"].ToString());
                }
                model.bz = dt.Rows[0]["bz"].ToString();
                model.zdr = dt.Rows[0]["zdr"].ToString();
                if (dt.Rows[0]["zdsj"] != null && dt.Rows[0]["zdsj"].ToString() != "")
                {
                    model.zdsj = DateTime.Parse(dt.Rows[0]["zdsj"].ToString());
                }
                model.shr = dt.Rows[0]["shr"].ToString();
                if (dt.Rows[0]["shsj"] != null && dt.Rows[0]["shsj"].ToString() != "")
                {
                    model.shsj = DateTime.Parse(dt.Rows[0]["shsj"].ToString());
                }
                model.sjfs = dt.Rows[0]["sjfs"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary> 
        /// 分页获取数据列表 
        /// </summary> 
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.DjLsh desc");
            }
            strSql.Append(")AS Row, T.*  from yw_pdbH T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex); return DbHelperSQL.Query(strSql.ToString());
        }


        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM yw_pdbH ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary> 
        /// 批量处理  
        /// </summary> 
        public int ExecuteSqlTran(List<string> ls, ref string error)
        {
            return DbHelperSQL.ExecuteSqlTran(ls, ref error);
        }

        /// <summary> 
        /// 获得前几行数据 
        /// </summary> 
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" * ");
            strSql.Append(" FROM yw_pdbH ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary> 
        /// 获得记录条数 
        /// </summary> 
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) ");
            strSql.Append(" FROM yw_pdbH ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj != null && obj.ToString() != "")
            {
                return Convert.ToInt32(obj);
            }
            else
                return 0;
        }

        public object GetSingle(string sql)
        {
            object obj = DbHelperSQL.GetSingle(sql);
            return obj;
        }
        public int  ExecuteSql(string sql)
        {
            int obj = DbHelperSQL.ExecuteSql(sql);
            return obj;
        }

    }

}
